<html>
  <head>
    <link type="text/css" rel="stylesheet" href="/stylesheets/sma.css" />
  </head>
  <body>
    <center>
    {% if action == 'list' %}
    <h1>Persons</h1>
      {% include "person_err.html" %}

      <table><tr>
          <th>&nbsp;
          <th>&nbsp;
          <th>First Name
          <th>Last Name
          <th>Phone Number
          <th>Email Address
          <th>Google User Name
          <th>Person Role(s)
      </tr>
      {% for p in plist %}
        <tr>
        <td><a href="/person/update?id={{p.key().id()}}">Edit</a>
        <td><a href="/person/delete?id={{p.key().id()}}">Delete</a>
        <td>{{p.p_firstname}}
        <td>{{p.p_lastname}}
        <td>{{p.p_phone}}
        <td>{{p.p_email}}
        <td>{{p.p_username}}
        <td>{{p.p_role}}
        </tr>
      {% endfor %}
      </table>
      <a href="/person/new">Add a new person</a>
      <br><a href="/">Back to group list</a>
    {% elif action == 'new' %}
    <h1>Adding a new person</h1>

      {% include "person_err.html" %}

    <form action="/person/new" method="post">
      <input type="hidden" name="action" value="new">
      <table><tr>
         <td>First Name
         <td><input type="text" name="fname" value="{{cache['fname']}}">
        </tr><tr>
         <td>Last Name
         <td><input type="text" name="lname" value="{{cache['lname']}}">
        </tr><tr>
         <td>Phone Number
         <td><input type="text" name="phone" value="{{cache['phone']}}">
        </tr><tr>
         <td>E-mail Address
         <td><input type="text" name="email" value="{{cache['email']}}">
        </tr><tr>
         <td>Google Username
         <td><input type="text" name="gname" value="{{cache['gname']}}">
        </tr><tr>
         <td>Person Roles:
         <td>{% for role in ['Member', 'Staff', 'Leader', 'Council'] %}
             <input type="checkbox" name="roles"
             value="{{role}}" />
             {{role}}
           {% endfor %}
      </tr></table>
      <input type="submit" name="submit" value="Cancel">
      <input type="submit" name="submit" value="Create">
    </form>
    {% elif action == 'view' %}
    <h1>view</h1>
    {% elif action == 'update' %}
    <h1>Updating {{cache['fname']}} {{cache['lname']}}</h1>

      {% include "person_err.html" %}

    <form action="/person/update" method="post">
      <input type="hidden" name="action" value="update">
      <input type="hidden" name="id"     value="{{id}}">
      <table><tr>
         <td>First Name
         <td><input type="text" name="fname" value="{{cache['fname']}}">
        </tr><tr>
         <td>Last Name
         <td><input type="text" name="lname" value="{{cache['lname']}}">
        </tr><tr>
         <td>Phone Number
         <td><input type="text" name="phone" value="{{cache['phone']}}">
        </tr><tr>
         <td>E-mail Address
         <td><input type="text" name="email" value="{{cache['email']}}">
        </tr><tr>
         <td>Google Username
         <td><input type="text" name="gname" value="{{cache['gname']}}">
        </tr><tr>
         <td>Person Roles
         <td>
           {% for role in ['Member', 'Staff', 'Leader', 'Council'] %}
           <input type="checkbox" name="roles" value="{{role}}"
                  {% if role in cache['roles'] %}
                  checked="1"
                  {% endif %}
                  /> {{role}}
           {% endfor %}
      </tr></table>
      <input type="submit" name="submit" value="Cancel">
      <input type="submit" name="submit" value="Update">
    </form>
    {% elif action == 'delete' %}
    <h1>Is this the one to delete?</h1>

      {% include "person_err.html" %}

    <form action="/person/delete" method="post">
      <input type="hidden" name="action" value="delete">
      <input type="hidden" name="id"     value="{{id}}">
      <table><tr>
         <td>First Name
         <td>{{cache['fname']}}
        </tr><tr>
         <td>Last Name
         <td>{{cache['lname']}}
        </tr><tr>
         <td>Phone Number
         <td>{{cache['phone']}}
        </tr><tr>
         <td>E-mail Address
         <td>{{cache['email']}}
        </tr><tr>
         <td>Google Username
         <td>{{cache['gname']}}
      </tr></table>
      <input type="submit" name="submit" value="Cancel">
      <input type="submit" name="submit" value="Delete">
    </form>
    {% endif %}

    </center>
  </body>
</html>
